<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./../Template/TemplateAccount.xhtml"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.org/ui">

    <ui:define name="content">
        <p:fieldset legend="LIST OF COMPLAINTS">
            <f:view>
                <h:form id="form">
                    <p:dataTable id="dttable" value="#{complaintBean.allByAccountID}" var="item" >
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="STT"/>
                            </f:facet>
                            <h:outputText value="#{item.complaintID}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="ComplaintCode"/>
                            </f:facet>
                            <h:outputText value="#{item.complaintNo}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Category"/>
                            </f:facet>
                            <h:outputText value="#{item.categoryID.categoryName}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="SendTimes" style="text-align: center"/>
                            </f:facet>
                            <h:outputText value="#{item.sendTimes}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="Status"/>
                            </f:facet>
                            <h:outputText value="#{item.status.statusName}" />
                        </p:column>
                        <p:column>
                            <p:commandButton value="Resend" action="#{complaintBean.resend()}"  update=":form:dttable">
                                <f:setPropertyActionListener value="#{item}" target="#{complaintBean.selectComplaint}" />
                            </p:commandButton>
                        </p:column>
                        <f:facet name="footer">
                            <p:commandButton id="Search" value="Search"
                                             onclick="dlg.show()"/>
                        </f:facet>
                    </p:dataTable>
                </h:form>

                <p:dialog header="Search Account" widgetVar="dlg" showEffect="drop" hideEffect="explode" width="790">
                    <h:form>
                        <p:dataTable id="dttable" value="#{complaintBean.allByAccountID}" var="item1" >
                            <p:column filterBy="#{item1.complaintNo}">
                                <f:facet name="header">
                                    <h:outputText value="ComplaintCode"/>
                                </f:facet>
                                <h:outputText value="#{item1.complaintNo}"/>
                            </p:column>
                            <p:column filterBy="#{item1.categoryID.categoryName}">
                                <f:facet name="header">
                                    <h:outputText value="Category"/>
                                </f:facet>
                                <h:outputText value="#{item1.categoryID.categoryName}"/>
                            </p:column>
                            <p:column filterBy="#{item1.sendTimes}">
                                <f:facet name="header">
                                    <h:outputText value="SendTimes" style="text-align: center"/>
                                </f:facet>
                                <h:outputText value="#{item1.sendTimes}"/>
                            </p:column>
                            <p:column filterBy="#{item1.status.statusName}">
                                <f:facet name="header">
                                    <h:outputText value="Status"/>
                                </f:facet>
                                <h:outputText value="#{item1.status.statusName}" />
                            </p:column>
                        </p:dataTable>
                    </h:form>
                </p:dialog>
            </f:view>
        </p:fieldset>
    </ui:define>
</ui:composition>
